package com.wechatapp.mengyao.poetry.vo;

import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.core.type.TypeReference;
import com.wechatapp.mengyao.poetry.constants.PoetryCollection;
import com.wechatapp.mengyao.poetry.core.JsonUtils;
import lombok.Data;

import java.util.List;

/**
 * @author yanghuaxu
 * @date 2025/6/12 10:23
 */
@Data
@JsonFilter("ChinesePoetryPageDTO")
public class ChinesePoetryPageView {

    private Integer id;

    private String author;

    private Integer authorId;

    private String authDescription;

    private String dynasty;

    private String title;

    private String contentString;

    private String collection;

    private List<String> content;

    private String isFavorite;

    private Integer poetryCount;

    public ChinesePoetryPageView convert() {
        this.content = JsonUtils.parseList(this.contentString, new TypeReference<List<String>>() {
        });
        this.collection = PoetryCollection.fromCode(this.collection);
        return this;
    }

}
